package site.yunnong.atvris.portal.spider.baidu;

import com.alibaba.fastjson.JSON;
import com.geccocrawler.gecco.pipeline.Pipeline;
import org.springframework.stereotype.Service;
import site.yunnong.atvris.portal.spider.VideoImportService;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zjh
 * @date 2021/8/31 11:17
 */
@Service("baiduPagePipeline")
public class BaiduPagePipeline implements Pipeline<BaiduPage> {
    
    @Resource(name = "baiduVideoImportServiceImpl")
    VideoImportService service;
    
    @Override
    public void process(BaiduPage bean) {
        System.out.println("执行到这里了");
        System.out.println(JSON.toJSONString(bean));
        List<BaiduVideo> baiduVideoList = bean.getBaiduVideoList();
        for (BaiduVideo baiduVideo : baiduVideoList) {
            service.importVideo(baiduVideo);
        }
        System.out.println("导入结束");
    }
}
